package android.demo.activity.list;

import android.content.Intent;
import android.demo.BaseActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListActivity extends BaseActivity {

	private static final int ListActivityA = 0;
	private static final int ListActivityB = 1;
	private static final int ListActivityC = 2;
	private static final int ListActivityD = 3;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		ListView mListView = new ListView(this);  
//		android.R.layout.simple_expandable_list_item_1
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_checked,  
				new String[] {"ArrayAdapter", "SimpleCursorAdapter", "SimpleAdapter", "BaseAdapter"}
		);  
		mListView.setAdapter(adapter);  
		
		mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				switch (position) {
					case ListActivityA :
						startActivity(new Intent(ListActivity.this, ListActivityA.class));
						break;
					case ListActivityB :
						startActivity(new Intent(ListActivity.this, ListActivityB.class));
						break;
					case ListActivityC :
						startActivity(new Intent(ListActivity.this, ListActivityC.class));
						break;
					case ListActivityD :
						startActivity(new Intent(ListActivity.this, ListActivityD.class));
						break;
				}   
			}
		});
		
		setContentView(mListView); 
	}
}
